package com.analyst.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

/**
 * ClassName: ResultVO
 * Package: com.analyst.dto
 * Description:
 *
 * @Author wk
 * @Create 2023/08/7 0007 下午 03:32:23
 * @Version 1.0
 */
@Setter
@Getter
@AllArgsConstructor
public class ResultVO {
    private Integer code;
    private String msg;
    private Object data;

    public ResultVO() {

    }

    public ResultVO(ResultCode resultCode, Object data) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
        this.data = data;
    }

    public static ResultVO success(Object data) {
        return new ResultVO(ResultCode.SUCCESS, data);
    }

    public static ResultVO failed(String errorMsg) {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(ResultCode.FAILED.getCode());
        resultVO.setMsg(errorMsg);
        return resultVO;
    }
}
